import random
import numpy as np


class Sampling:

    @staticmethod
    def randomPartition(data, blocks):
        rows = data.shape[0]
        assert rows % blocks == 0

        idxs = list(range(rows))
        random.shuffle(idxs)
        idxs = np.reshape(idxs, (blocks, -1))

        randomSampleBlocks = []
        for blockidxs in idxs:
            randomSampleBlocks.append(data[blockidxs])

        return randomSampleBlocks
